<style scoped src="./index.scss" lang="scss" rel="stylesheet/scss"></style>
<template src="./index.html"></template>
<script>
export default {
  mixins: [Vue.prototype.$vFN.Mixins.Base, Vue.prototype.$vFN.Mixins.Edit, Vue.prototype.$vFN.Utils],
  components: {},
  data() {
    return {
      appWindow: window,
      editVisible: true,
      //用户选择日期范围
      dateData: "",

      // 导出文件的数据
      exportData: {
        name: {
          type: String,
          value: "",
          default: "",
        },
        publishStatus: {
          type: Number,
          value: null,
          default: null,
        },

        // 商品分组一级ID
        groupsId: {
          type: Number,
          value: null,
          default: null,
        },
        // 商品分组二级ID
        subGroupsId: {
          type: Number,
          value: null,
          default: null,
        },
        minPrice: {
          type: Number,
          value: 0,
          default: 0,
        },
        maxPrice: {
          type: Number,
          value: 1000000,
          default: 1000000,
        },
        productTypeLst: {
          type: Array,
          value: null,
          default: null,
        },
        // 商品标签
        labelIdLst: {
          type: Array,
          value: null,
          default: null,
        },
        // 商品品牌
        brandIdLst: {
          type: Array,
          value: null,
          default: null,
        },
        // 商品属性
        attributeValueIdLst: {
          type: Array,
          value: null,
          default: null,
        },
        // 商品服务
        serveValueIdLst: {
          type: Array,
          value: null,
          default: null,
        },

        putAwayTimeStartStr: {
          type: String,
          // '2020-02-02 09:09:09',
          value: "",
          default: "",
        },
        putAwayTimeEndStr: {
          type: String,
          // '2020-02-02 09:09:09',
          value: "",
          default: "",
        },
      },
    };
  },

  methods: {
    // 初始化
    async init() {},
    // 导出报表
    async exportTable() {
      let dataObj_ = {};
      for (const key in this.exportData) {
        dataObj_[key] = this.exportData[key].value;
      }

      let res = await this.$vFN.Http.post(
        {
          url: "mall-site-portal/product/exportProductList",
          data: dataObj_,
        },
        window
      );

      if (res._ok) {
        this.$vFN.Tools.messageSuccess("操作成功，请到下载中心查看");
        this.editVisible = false;
      }
    },
    // 清空导出筛选
    clearExport() {
      for (const key in this.exportData) {
        this.exportData[key].value = this.exportData[key].default;
      }

      this.dateData = "";
    },

    // 上下架日期
    dateSelect(){

      if(this.$vFN.Utils.isEmpty(this.dateData)){
        this.exportData.putAwayTimeStartStr.value = "";
        this.exportData.putAwayTimeEndStr.value ="";
      }else{
        // 开始时间
        this.exportData.putAwayTimeStartStr.value = this.dateData[0];
        // 结束时间
        this.exportData.putAwayTimeEndStr.value = this.dateData[1];
      }

    },

    // 提交成功
    onSubmitSuccess() {
      this.onSuccess();
    },
    // 成功回调
    onSuccess() {},
    // 取消回调
    onCancel() {},
    // 失败回调
    onError() {},
  },
  mounted() {
    this.init();
  },
  activated() {},
};
</script>